/**
 * 
 */
package fr.lelouet.ga.algorithmes;

import java.util.Set;

import fr.lelouet.ga.*;

/**
 * An algorithm which behaviour is given as the constructor parameters.
 * @author le louet
 */
public class InternalBehaviour<T> extends AAlgorithme<T> {

  protected Combinator<T> combinator;

  protected Generator<T> generator;

  protected Mutator<T> mutator;

  protected Reducer<T> reducer;

  protected Stopper<T> stopper;

  public InternalBehaviour(final Generator<T> generator,
      final Stopper<T> stopper, final Reducer<T> reducer,
      final Combinator<T> combinator, final Mutator<T> mutator) {
    this.generator = generator;
    this.stopper = stopper;
    this.reducer = reducer;
    this.combinator = combinator;
    this.mutator = mutator;

    this.reinit();
  }

  @Override
  public Set<T> combination(final Set<T> set) {
    return this.combinator.combination(set);
  }

  @Override
  public Generation<T> generate() {
    return this.generator.generate();
  }

  @Override
  public void mute(final Set<T> set) {
    this.mutator.mute(set);
  }

  @Override
  public boolean stop(final Generation<T> generation) {
    return this.stopper.stop(generation);
  }

  @Override
  public Set<T> toReduce(final Set<T> set) {
    return this.reducer.toReduce(set);
  }

  @Override
  public void restart() {
    this.stopper.restart();
  }

}
